package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.pojo.Anniversary;

import java.util.List;

/**
* @author LENOVO
* @description 针对表【Anniversary(纪念日表)】的数据库操作Mapper
* @createDate 2024-04-03 20:56:19
* @Entity org.example.pojo.Anniversary
*/
@Mapper
public interface AnniversaryMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Anniversary record);

    int insertSelective(Anniversary record);

    Anniversary selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Anniversary record);

    int updateByPrimaryKey(Anniversary record);

    @Insert("insert into Anniversary(anniversary_name, anniversary_date, background_image_url, anniversary_id) values " +
            "(#{anniversaryName}, #{anniversaryDate}, #{url}, #{userId})")
    void addAnniversary(String anniversaryName, String anniversaryDate, String url, Integer userId);

    @Select("select * from Anniversary where anniversary_id=#{userId}")
    List<Anniversary> list(Integer userId);

    @Select("select Anniversary.background_image_url from Anniversary where id=#{id}")
    String findByURL(Integer id);

    @Update("update Anniversary set anniversary_name=#{anniversaryName},anniversary_date=#{anniversaryDate} where id=#{id}")
    void editAnniversary(Integer id, String anniversaryName, String anniversaryDate);

    @Update("update Anniversary set background_image_url=#{url} where id=#{id}")
    void editPhon(Integer id, String url);

    @Delete("delete from Anniversary where id=#{id}")
    void deleteAnniversary(Integer id);
}
